<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" lang="zh-CN">

<div class="container">
    <form th:if="${#strings.isEmpty(key)}" class="form-horizontal" role="form">
        <div class="row text-center">
            <div class="page-header">
                <h3>社区版暂未开放，请下载<a href="https://gitee.com/ghi/dbsyncer/releases" title="下载专业版dbsyncer-enterprise-x.x.x-bin.zip " target='_blank'>专业版</a></h3>
            </div>
            <div class="page-information">
                <img draggable="false" th:src="@{'/img/license/enterprise.png'}">
            </div>
        </div>
    </form>

    <form id="licenseForm" th:if="${not #strings.isEmpty(key)}" class="form-horizontal" role="form">
        <div class="row text-center">
            <div class="page-header">
                <h3>授权许可<img th:if="${productInfo?.products?.size() gt 0}" draggable="false" title="授权成功" width="28px" height="28px" th:src="@{'/img/license/check.png'}"></h3>
            </div>
        </div>
        <div class="form-group" th:if="${productInfo?.products?.size() gt 0}">
            <address>
                <strong>[[${productInfo?.company}]]</strong><br>
                申请人：[[${productInfo?.owner}]]<br>
                授权时间：[[${#dates.format(productInfo?.createTime, 'yyyy-MM-dd HH:mm:ss')}]]<br>
                <abbr>备注：</abbr>[[${productInfo?.remark}]]
            </address>
            <table class="table table-hover">
                <thead>
                <tr>
                    <th></th>
                    <th>产品名称</th>
                    <th>有效期限</th>
                </tr>
                </thead>
                <tbody>
                <tr th:id="${p?.name}" th:each="p,state : ${productInfo?.products}">
                    <td>[[${state.index+1}]]</td>
                    <!-- 有效期 -->
                    <td th:if="${#dates.createNow()?.time} < ${p?.effectiveTime} and ${p?.effectiveTime} - 864000000 > ${#dates.createNow()?.time}">[[${p?.name}]]&nbsp;<img draggable="false" width="20px" height="20px" th:src="@{'/img/license/check.png'}"></td>
                    <!-- 即将过期 -->
                    <td th:if="${#dates.createNow()?.time} < ${p?.effectiveTime} and ${p?.effectiveTime} - 864000000 <= ${#dates.createNow()?.time}">[[${p?.name}]]&nbsp;<img draggable="false" width="20px" height="20px" title="即将过期, 请联系星河同步官方续期" th:src="@{'/img/license/remind.png'}"></td>
                    <!-- 已过期 -->
                    <td th:if="${#dates.createNow()?.time} > ${p?.effectiveTime}">[[${p?.name}]]&nbsp;<img draggable="false" width="20px" height="20px" title="已过期, 请联系星河同步官方续期" th:src="@{'/img/license/warning.png'}"></td>
                    <td th:text="${#dates.format(p?.effectiveTime, 'yyyy-MM-dd HH:mm:ss')}"/>
                </tr>
                </tbody>
            </table>
            <div class="text-right">
                <button id="removeBtn" class="btn btn-default" type="button">删除激活码</button>
            </div>
        </div>

        <div id="qrcode" class="hidden"></div>
        <div th:if="${productInfo?.products?.size() lt 0}">
            <div class="form-group">
                <div class="row">
                    <div class="col-md-12">
                        <label>公司名称</label>
                        <input class="form-control" type="text" name="company" maxlength="64" th:value="${company}"/>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <div class="col-md-12">
                        <label>申请人</label>
                        <input class="form-control" type="text" name="owner" maxlength="32" th:value="${userInfo?.nickname}"/>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <div class="col-md-12">
                        <label>手机号</label>
                        <input class="form-control" type="text" name="phone" maxlength="11" th:value="${userInfo?.phone}"/>
                        <small class="text-muted">便于通过短信提前通知您授权情况</small>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <div class="col-md-12">
                        <label>邮箱<i class="fa fa-question-circle fa_gray" aria-hidden="true" title="支持多个邮箱"></i></label><br />
                        <input class="form-control" type="text" max="100" min="1" name="email" data-role="tagsinput" th:value="${userInfo?.email}"/>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <div class="col-md-12">
                        <label>备注</label>
                        <textarea name="remark" class="form-control dbsyncer_textarea_resize_none" maxlength="64" rows="3" />
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <div class="col-md-12">
                        <button id="activateBtn" th:if="${productInfo?.products?.size() lt 0}" class="btn btn-primary" type="button" th:title="填写的信息会严格保密，我们不会向其他人共享您的信息">在线激活(免费使用15天)</button>
                    </div>
                </div>
            </div>

            <hr/>
            <div class="row">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">离线激活（无法访问互联网时） 1.复制机器码给 <a href="javascript:;" id="myService" class="text-success"><span class='fa fa-wechat'></span>星河同步官方</a> 帮您生成License文件; 2.上传License文件</h3>
                    </div>
                    <div class="panel-body">
                        <div class="input-group">
                            <input id="licenseKey" type="text" class="form-control text-primary" readonly="readonly" th:value="${key}">
                            <span class="input-group-btn"><button id="copyBtn" class="btn btn-default" type="button" th:title="复制机器码"><i class="fa fa-copy"></i>&nbsp;复制</button></span>
                        </div>
                        <br />
                        <div class="file-loading">
                            <input id="fileLicense" type="file" name="files" multiple="multiple"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>

<script th:src="@{/js/license/license.js}"></script>
</html>